package com.example.e.Adapter

import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.example.e.R
import com.example.e.data.ShopSearchHistory

class ShopHistoryAdapter (val history_shop_data:List<ShopSearchHistory>):
    RecyclerView.Adapter<ShopHistoryAdapter.ShopHistoryViewHolder>() {

    class ShopHistoryViewHolder(view: View):RecyclerView.ViewHolder(view){
        val tvShopHistory: TextView = view.findViewById(R.id.tvShopHistory)
    }


    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ShopHistoryViewHolder {
        val view = LayoutInflater.from(parent.context).inflate(R.layout.elem_history_layout,parent,false)
        return ShopHistoryViewHolder(view)
    }

    override fun onBindViewHolder(holder: ShopHistoryViewHolder, position: Int) {
        if (!history_shop_data.isEmpty()) {
            val info = history_shop_data[position]
            holder.tvShopHistory.text = "${info.name}"
        }
    }
    override fun getItemCount() = history_shop_data.size

}
